package com.atguigu.easyexcel;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.atguigu.easyexcel.entity.ExcelStudentData;
import org.junit.Test;

import javax.xml.crypto.Data;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author dyqstart
 * @create 2021-07-07-11:40
 * @since 1.0.0
 */
public class ExcelWriteTest {


    /**
     * 最简单的写
     */
    @Test
    public void simpleWrite07(){
        //需要提前新建目录
        String fileName = "F:\\code2021\\workspaceidea\\springcloud\\alibaba-easyexcel\\01-simpleWrite-07.xlsx";
        EasyExcel.write(fileName, ExcelStudentData.class).sheet("员工信息统计表").doWrite(data());
    }

    @Test
    public void simpleWrite03(){
        String fileName = "F:\\code2021\\workspaceidea\\springcloud\\alibaba-easyexcel\\01-simpleWrite-03.xls";
        EasyExcel.write(fileName,ExcelStudentData.class).excelType(ExcelTypeEnum.XLS).sheet("员工信息统计表03").doWrite(data());
    }

    private List<ExcelStudentData> data() {
        List<ExcelStudentData> list = new ArrayList<>();
        for (int i = 0; i < 65535; i++) {
            ExcelStudentData data = new ExcelStudentData();
            data.setName("康师傅"+i);
            data.setBirthday(new Date());
            data.setSalary(1000000.1234);
            data.setPassword("123");//设置因为有ignore也会被忽略不导入
            list.add(data);
        }
        return list;
    }
}
